package com.pianke.yc.test.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.pianke.yc.test.Classess.Job;
import com.pianke.yc.test.R;

import java.util.List;

/**
 * Created by YC on 2016/3/30.
 */
public class JobAdapter  extends BaseAdapter{
    private List<Job> mJobs;
    private LayoutInflater mInflater;
    public JobAdapter(Context context,List<Job> jobs){
        mInflater=LayoutInflater.from(context);
        mJobs=jobs;

    }

    @Override
    public int getCount() {
        return mJobs.size();
    }

    @Override
    public Object getItem(int position) {
        return mJobs.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder v=new ViewHolder();
        if(convertView==null){
            convertView=mInflater.inflate(R.layout.item,null);
            convertView.setTag(v);
        }else{
            v= (ViewHolder) convertView.getTag();
        }

        v.title= (TextView) convertView.findViewById(R.id.accept_item_title);
        v.city=(TextView)convertView.findViewById(R.id.accept_item_city);

        v.title.setText(mJobs.get(position).title);
        v.city.setText(mJobs.get(position).city);

        return convertView;
    }

    class ViewHolder{
        TextView title;
        TextView city;
    }
}
